import { Menu, Tray, app } from "electron";
import { ICON } from "./utils";
import { showMainWin } from "../win/mainWin";

export const initTray = () => {
  let appIcon = new Tray(ICON);
  const contextMenu = Menu.buildFromTemplate([
    {
      label: "主页面",
      click: () => {
        showMainWin();
      },
    },
    {
      label: "重启",
      click: () => {
        app.relaunch();
        app.exit(0);
      },
    },
    {
      label: "退出",
      click: () => {
        app.quit();
      },
    },
  ]);
  appIcon.setToolTip("梨子REC");
  appIcon.setContextMenu(contextMenu);

  appIcon.addListener("click", function () {
    showMainWin();
  });

  return appIcon;
};
